package com.mall.product.service.impl;

import com.mall.common.domain.MallProduct;
import com.mall.common.domain.MallUser;
import com.mall.common.domain.Numbers;
import com.mall.common.domain.request.MallProductRequest;
import com.mall.product.mapper.ProductInfoMapper;
import com.mall.product.service.ProductInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangy
 * @version 1.0
 * @description: TODO
 */
@Service
public class ProductInfoServiceImpl implements ProductInfoService {
    @Resource
    private ProductInfoMapper productInfoMapper;
    /**
     * 选择产品列表
     *
     * @param mallProductRequest 参数
     * @return List<MallProduct>
     */
    @Override
    public List<MallProduct> selectProductList(MallProductRequest mallProductRequest) {
        return productInfoMapper.selectProductList(mallProductRequest);
    }

    /**
     * 添加商品信息
     * @param mallProduct 参数
     */
    @Override
    public void addProduct(MallProduct mallProduct) {
        productInfoMapper.addProduct(mallProduct);
    }

    @Override
    public void updateProduct(Integer id) {
        MallProduct productById = productInfoMapper.findProductById(id);
        productById.setSpellNumber(productById.getSpellNumber()+1);
        productInfoMapper.updateProduct(productById);
    }
    @Override
    public void updateProduct2(Integer id) {
        MallProduct productById = productInfoMapper.findProductById(id);
        productById.setSpellNumber(productById.getSpellNumber()-1);
        productInfoMapper.updateProduct(productById);
    }


    @Override
    public List<Numbers> statisticsUser() {
        return productInfoMapper.numbers();
    }
}
